home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / CDE / O-Z / Print2Pict3.4.cpt / Print2Pict 3.4ƒ / P2P Extentions ƒ / Print to PICS ƒ / tools.c < prev    next >
Text File  |  1992-05-24  |  2KB  |  109 lines

  1. /*===================
  2.  
  3.     Utility routines.
  4.     
  5.     © B.Raoult 92
  6.  
  7. ====================*/
  8. #include "tools.h"
  9.  
  10. /*
  11.     Returns the rectangle of a dialog item 
  12. */
  13.  
  14. Rect GetItemR(DialogPtr dialog, short itemno)
  15. {    
  16.     Rect     box;
  17.     short     type;
  18.     Handle    item;
  19.     
  20.     GetDItem(dialog,itemno,&type,&item,&box);
  21.     return box;
  22. }
  23.  
  24. /*
  25.     Returns the handle of a dialog item 
  26. */
  27.  
  28. Handle GetItemH(DialogPtr dialog, short itemno)
  29. {    
  30.     Rect     box;
  31.     short     type;
  32.     Handle    item;
  33.     
  34.     GetDItem(dialog,itemno,&type,&item,&box);
  35.     return item;
  36. }
  37.  
  38. /*
  39.     Sets a checkbox
  40. */
  41.  
  42. void SetCheck(DialogPtr dialog,short itemno,Boolean on_off)
  43. {
  44.     SetCtlValue(GetItemH(dialog,itemno),on_off);
  45. }
  46.  
  47. /*
  48.     Get the value of a checkbox
  49. */
  50.  
  51. Boolean GetCheck(DialogPtr dialog, short itemno)
  52. {
  53.     return GetCtlValue(GetItemH(dialog,itemno));
  54. }
  55.  
  56. /*
  57.     Toggle a checkbox, returns the new status
  58. */
  59.  
  60. Boolean ClickCheck(DialogPtr dialog, short itemno)
  61. {
  62.     Handle    item = GetItemH(dialog,itemno);
  63.     
  64.     SetCtlValue(item,1-GetCtlValue(item));
  65.     return GetCtlValue(item);
  66. }
  67.  
  68. /*
  69.     Put a long integer into an edittext.
  70. */
  71.  
  72.  
  73. void Long2Dialog(DialogPtr dialog, short itemno, long value)
  74. {
  75.     Str255    buf;
  76.     
  77.     NumToString(value,buf);
  78.     SetIText(GetItemH(dialog,itemno),buf);
  79.  
  80. }
  81.  
  82. /*
  83.     Get a long integer from an edittext.
  84. */
  85.  
  86.  
  87. long Dialog2Long(DialogPtr dialog, short itemno)
  88. {
  89.     Str255    buf;
  90.     long    value;
  91.     
  92.     GetIText(GetItemH(dialog,itemno),buf);
  93.     StringToNum(buf,&value);
  94.     return value;
  95.  
  96. }
  97.  
  98. /*
  99.     Checks if color quickdraw is here. I know, I should use Gestalt...
  100. */
  101.  
  102.  
  103. Boolean HasColor(void)
  104. {
  105.     SysEnvRec s;
  106.     if(SysEnvirons(1,&s) == noErr) return s.hasColorQD;
  107.     return false;
  108. }
  109.